# 列表   有序(插入顺序) 不唯一

l = [1, 2, 3, 4, 5, 6, 7, 8, 9]

l.append(10)
print(l)
print(l[1])

del l[2]
print(l)

print(l.pop(2))
print(l)
l.insert(2, 100)
print(l)

print(l[0])
print(l[-1])

print(len(l))

l = [1, 2, 3, 4, 5, 6, 7, 8, 9]

print(l[2:7])

# 取出奇数
print(l[0::2])

# 赋值列表
print(l[:])

# 反转
print(l[::-1])
# l.reverse()
print(l)

print(l[-1:-5:-1])

print("=" * 100)

ll = [[1, 2, 3],
      [4, 5, 6],
      [7, 8, 9]]

print(ll[1])
print(ll[1][1])

#  元组    不可变列表

t = (1, 2, 3, 4, 5)

# 不能修改列表
# del t[1]

print(t)

#  字典

m = {"k1": "v1", "k2": "v3", "k3": "v3", }

print(m)

print(m.get("k1"))
print(m["k1"])

# 增加或是更新元素
m["k4"] = "v4"

print(m)

del m["k1"]
print(m)

print(m.pop("k2"))
print(m)

print(m.keys())
print(m.values())

print("k4" in m)

print(m.items())

for k, v in m.items():
    print(k, v)

m.clear()
print(m)

#  集合  无序 唯一
s = {1, 2, 3, 4, 5, 6, 1}
print(s)

s.add(10)
print(s)

print(s.pop())

print(s)

s1 = {1, 2, 3, 4, 5, 6}
s2 = {4, 5, 6, 7, 8, 9}

print(s1 & s2)
print(s1 | s2)
print(s1 ^ s2)
print(s1 - s2)
